const router = require('koa-router')()

const upload = require('../controller/upload')
const fileHandle = require('../controller/fileHandle')
router.prefix('/upload')
// #region
/**
 * @swagger
 * /upload/image:
 *   post:
 *     description: 上传图片
 *     tags: [文件模块]
 *     produces:
 *       - multipart/form-data
 *     parameters:
 *       - name: file
 *         description: 字段名
 *         in: formData
 *         required: true
 *         type: file
 *     responses:
 *       0:
 *         description: 成功
 */
// #endregion
router.post('/image', upload.image)

// #region
/**
 * @swagger
 * /fileHandle/qiniuImage 上传图片文件到七牛云:
 *   post:
 *     description: 上传图片文件到七牛云
 *     tags: [文件操作模块]
 *     produces:
 *       - multipart/form-data
 *     parameters:
 *       - name: file
 *         description: 字段名
 *         in: formData
 *         required: true
 *         type: file
 *     responses:
 *       0:
 *         description: 成功
 */
// #endregion
router.post('/qiniuImage', upload.qiniuImage)
// #region
/**
 * @swagger
 * /fileHandle/getImageUrl 根据单个或多个id取的文件信息:
 *   post:
 *     description: 根据单个或多个id取的文件信息 （多个id:10000,10002）
 *     tags: [文件操作模块]
 *     produces:
 *       - application/json
 *     parameters:
 *       - name: ids
 *         description: 文件id，使用字符串,拼接多个
 *         in: formData
 *         required: true
 *         type: string
 *     responses:
 *       0:
 *         description: 成功
 *         schema:
 *           type: object
 *           $ref: '#/definitions/success'
 *       -1:
 *         description: 失败
 *         schema:
 *           type: object
 *           $ref: '#/definitions/fail'
 */
// #endregion
router.post('/getImageUrl', fileHandle.getImageUrl)
router.delete('/deleteImage', fileHandle.deleteImage)
router.delete('/deleteLocalImage', fileHandle.deleteLocalImage)
module.exports = router
